﻿var status = 0;
var choice;
var scrolls = Array(
Array("", 5170000, 0),
Array("", 5000000, 9999999),
Array("", 5000001, 9999999),
Array("", 5000002, 9999999),
Array("", 5000003, 9999999),
Array("", 5000004, 9999999),
Array("", 5000005, 9999999),
Array("", 5000006, 9999999),
Array("", 5000007, 9999999),
Array("", 5000008, 9999999),
Array("", 5000009, 9999999),
Array("", 5000010, 9999999),
Array("", 5000011, 9999999),
Array("", 5000012, 9999999),
Array("", 5000013, 9999999),
Array("", 5000014, 9999999),
Array("", 5000015, 9999999),
Array("", 5000016, 9999999),
Array("", 5000017, 9999999),
Array("", 5000018, 9999999),
Array("", 5000020, 9999999),
Array("", 5000021, 9999999),
Array("", 5000022, 9999999),
Array("", 5000023, 9999999),
Array("", 5000024, 9999999),
Array("", 5000025, 9999999),
Array("", 5000026, 9999999),
Array("", 5000027, 9999999),
Array("", 5000028, 9999999),
Array("", 5000029, 9999999),
Array("", 5000030, 9999999),
Array("", 5000031, 9999999),
Array("", 5000032, 9999999),
Array("", 5000033, 9999999),
Array("", 5000035, 9999999),
Array("", 5000036, 9999999),
Array("", 5000038, 9999999),
Array("", 5000040, 9999999),
Array("", 5000041, 9999999),
Array("", 5000042, 9999999),
Array("", 5000043, 9999999),
Array("", 5000044, 9999999),
Array("", 5000046, 9999999),
Array("", 5000047, 9999999),
Array("", 5000048, 9999999),
Array("", 5000049, 9999999),
Array("", 5000050, 9999999),
Array("", 5000051, 9999999),
Array("", 5000052, 9999999),
Array("", 5000053, 9999999),
Array("", 5000054, 9999999),
Array("", 5000055, 9999999),
Array("", 5000056, 9999999),
Array("", 5000060, 9999999),
Array("", 5000064, 9999999),
Array("", 5000065, 9999999),
Array("", 5000066, 9999999),
Array("", 5000067, 9999999),
Array("", 5000068, 9999999),
Array("", 5000069, 9999999),
Array("", 5000070, 9999999),
Array("", 5000071, 9999999),
Array("", 5000072, 9999999),
Array("", 5000075, 9999999),
Array("", 5000076, 9999999),
Array("", 5000077, 9999999),
Array("", 5000081, 9999999),
Array("", 5000083, 9999999),
Array("", 5000084, 9999999),
Array("", 5000085, 9999999),
Array("", 5000086, 9999999),
Array("", 5000087, 9999999),
Array("", 5000088, 9999999),
Array("", 5000089, 9999999),
Array("", 5000090, 9999999),
Array("", 5000091, 9999999),
Array("", 5000092, 9999999),
Array("", 5000093, 9999999),
Array("", 5000094, 9999999),
Array("", 5000095, 9999999),
Array("", 5000096, 9999999),
Array("", 5000098, 9999999),
Array("", 5000103, 9999999),
Array("", 5000112, 9999999),
Array("", 5000113, 9999999),
Array("", 5000128, 9999999),
Array("", 5000137, 9999999),
Array("", 5000152, 9999999),
Array("", 5000201, 9999999),
Array("", 5000202, 9999999),
Array("", 5000203, 9999999),
Array("", 5000204, 9999999),
Array("", 5000205, 9999999),
Array("", 5000206, 9999999),
Array("", 5000207, 9999999),
Array("", 5000208, 9999999),
Array("", 5000209, 9999999),
Array("", 5000210, 9999999),
Array("", 5000211, 9999999),
Array("", 5000212, 9999999),
Array("", 5000213, 9999999),
Array("", 5000214, 9999999),
Array("", 5000215, 9999999),
Array("", 5000216, 9999999),
Array("", 5000217, 9999999),
Array("", 5000221, 9999999),
Array("", 5000225, 9999999),
Array("", 5000227, 9999999),
Array("", 5000228, 9999999),
Array("", 5000229, 9999999),
Array("", 5000230, 9999999),
Array("", 5000231, 9999999),
Array("", 5000232, 9999999),
Array("", 5000233, 9999999),
Array("", 5000237, 9999999),
Array("", 5000238, 9999999),
Array("", 5000239, 9999999),
Array("", 5000240, 9999999),
Array("", 5000243, 9999999),
Array("", 5000244, 9999999),
Array("", 5000245, 9999999),
Array("", 5000267, 9999999),
Array("", 5000268, 9999999),
Array("", 5000274, 9999999)
);

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) cm.dispose();
    else {
        if (status == 0 && mode == 0) {
            cm.dispose();
            return;
        } else if (status >= 1 && mode == 0) {
            cm.sendOk("好吧，欢迎下次继续光临！.");
            cm.dispose();
            return;
        }
        if (mode == 1) status++;
        else status--;

        if (status == 0) {
            choices = "\r\n兔兔币余额：#r" + cm.getHyPay(1) + "#k个 (#r请使用工具发送#k)";
            for (var i = 0; i < scrolls.length; i++) {
                choices += "\r\n#L" + i + "##v" + scrolls[i][1] + "##z" + scrolls[i][1] + "#　#d需要#r" + scrolls[i][2] + "#d兔兔币#k#l";
            }
            cm.sendSimpleS("欢迎来到宠物之家,这里只供预浏览作用，购买会掉线：." + choices,2);
        } else if (status == 1) {
            cm.sendYesNo("你确定需要购买#v" + scrolls[selection][1] + "##t" + scrolls[selection][1] + "#?");
		choice = selection;
        } else if (status == 2) {
            var money = scrolls[choice][2];
            if (cm.getHyPay(1) < money) {
                cm.sendOk("抱歉，你没足够的兔兔币！");
                cm.dispose();
            } else {
                cm.addHyPay(money);
                cm.gainItem(scrolls[choice][1], 1);
                cm.sendOk("购买成功.");
                cm.dispose();
            }
        }
    }
}